#include <stdio.h>
#include <stdlib.h>

int main()
{
    typedef struct {
        int num;
        char name[10];
        char sex;
        char job;
        union {
            int class;
            char position[10];
        } category;
    } person;

    int num;
    scanf(" %d", &num);
    person *person_list;
    person_list = (person*)malloc(sizeof(person) * num);

    for(int i = 0; i < num; i++) {
        scanf(" %d", &person_list[i].num);
        scanf(" %s", person_list[i].name);
        scanf(" %c", &person_list[i].sex);
        scanf(" %c", &person_list[i].job);
        switch(person_list[i].job) {
            case 's':
                scanf(" %d", &person_list[i].category.class);
                break;
            case 't':
                scanf(" %s", person_list[i].category.position);
                break;
        }
    }

    for (int i = 0; i < num; i++) {
        printf("%d %s %c %c ", person_list[i].num, person_list[i].name,
               person_list[i].sex, person_list[i].job);
        if (person_list[i].job == 's')
            printf("%d\n", person_list[i].category.class);
        else
            printf("%s\n", person_list[i].category.position);
    }
}